<template>
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header"><i class="fa fa-remove"></i> 销户</div>
        <div class="layui-card-body">
            <div class="layui-form-item">
                <img src="/loginImg/closeAccount.jpg" alt="" class="tranferimg" style="    width: 50%;float:left;">
                <span class="my_span">销户</span>
                <input type="text" v-model="cardId" maxlength="18" lay-verify="title" autocomplete="off" placeholder="请输入需销账户" class="layui-input my_input" oninput = "value=value.replace(/[^\d]/g,'')"> 
                <input type="text" v-model="uname" lay-verify="title" autocomplete="off" placeholder="请输入需销账户名" class="layui-input my_input">     
                <input type="text" v-model="uid" maxlength="18" lay-verify="title" autocomplete="off" placeholder="请输入需销账户身份证" class="layui-input my_input" oninput = "value=value.replace(/[^\d]/g,'')">     
                <input type="text" v-model="utelephone" maxlength="11" lay-verify="required" placeholder="请输入需销账户11位电话号码" autocomplete="off" class="layui-input my_input" oninput = "value=value.replace(/[^\d]/g,'')">
                <button class="btn btn-primary" @click.prevent="closeAccount" data-dismiss="modal" style="width: 45%;margin-top:15px;position: relative;left: 3%;">销户</button>
            </div>
        </div>
      </div>
    </div>
</template>
<script>
import Qs from 'qs'
export default {
    inject:['reload'],
    data (){
        return {
            uid:'',
            uname:'',
            cardId:'',
            utelephone:''
        }
    },
    methods:{
        closeAccount:function(){//账户冻结
            var accountIdRegix=/^[\d]{18}$/;
            var teleRegix=/^[\d]{11}$/;
            if(!this.cardId.match(accountIdRegix)){
                 this.$message.error("账户需要18位");
                return false;
            }else if(!this.uid.match(accountIdRegix)){
                this.$message.error("身份证需要18位");
                return false;
            }else if(!this.utelephone.match(teleRegix)){
                this.$message.error("电话号码需要11位");
                return false;
            }else{
                var data=Qs.stringify({
                "cardId":this.cardId,
                "uname":this.uname,
                "uid":this.uid,
                "utelephone":this.utelephone
                })
                this.$axios
                .post('/bk-user/closeAccount',
                        data,
                        {headers:{'Content-Type':'application/x-www-form-urlencoded'}}
                )
                .then(result => {
                    if(result.data.code===200){
                        this.$message.error(result.data.message);
                        this.reload();
                    }else{
                        this.$message.error(result.data.message);
                        alert(result.data.message);
                    }
                })
                .catch(failResponse => {
                    
                })
            }
        }
    }
}
</script>
<style>
    .my_input{
        width: 45%;
        margin-top:30px;
        position: relative;
        left: 3%;
    }
    .my_span{
        display:inline-block;
        margin-top:10px;
        margin-bottom:10px;
        position: relative;
        left: 3%;    
        color: lightgray;
        font-size: 25px;
    }
</style>
